package com.chainyoung.component_tmperson.ui.adapter;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chainyoung.common.imageloader.ImageLoader;
import com.chainyoung.common.imageloader.glide.GlideImageConfig;
import com.chainyoung.common.utils.ToastUtil;
import com.chainyoung.common.utils.Utils;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.entity.PurseAddrItem;

import java.util.List;

public class MyPurseAddrAdapter extends BaseQuickAdapter<PurseAddrItem, BaseViewHolder> {


    private ImageLoader imageLoader;

    private View.OnClickListener onClickListener;

    private View.OnLongClickListener onLongClickListener;

    public MyPurseAddrAdapter(Context context, @Nullable List<PurseAddrItem> data) {
        super(R.layout.tmperson_list_purse_addr_item, data);
        mContext = context;
        imageLoader = Utils.getAppComponent().imageLoader();

    }

    @Override
    protected void convert(final BaseViewHolder helper, final PurseAddrItem item) {
        imageLoader.loadImage(mContext,
                GlideImageConfig
                        .builder()
                        .url(item.getImg())
                        .imagerView((ImageView) (helper.getView(R.id.iv_logo)))
                        .build());

        helper.setText(R.id.tv_simple_name, item.getName());
        helper.setText(R.id.tv_total_name, item.getAddr());
        helper.getView(R.id.rl_addr).setOnClickListener(onClickListener);
        helper.getView(R.id.rl_addr).setTag(helper.getAdapterPosition());
        helper.getView(R.id.rl_addr).setOnLongClickListener(onLongClickListener);

    }


    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    public void setOnLongClickListener(View.OnLongClickListener onLongClickListener) {
        this.onLongClickListener = onLongClickListener;
    }
}
